package com.Policing.Check;

import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.TextView;

import com.Policing.R;

import java.util.List;

/**
 * Created by Administrator on 2019/5/5.
 */

public class Check_Adapter extends ArrayAdapter {
    public Check_Adapter(Context context, int resource, List<Check_item_bean> objects) {

        super(context, resource, objects);
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        final Check_item_bean linkeMain = (Check_item_bean)getItem(position);
        final View view = LayoutInflater.from(getContext()).inflate(R.layout.check_item, null);
        TextView checkdetailId = (TextView) view.findViewById(R.id.checkdetailId);
        TextView type = (TextView) view.findViewById(R.id.type);
        TextView assetNumber = (TextView) view.findViewById(R.id.assetNumber);
        TextView deptId = (TextView)view.findViewById(R.id.deptId);
        TextView result = (TextView)view.findViewById(R.id.result);
        TextView plannum = (TextView)view.findViewById(R.id.plannum);
        final EditText realitynum = (EditText)view.findViewById(R.id.realitynum);
        checkdetailId.setText(linkeMain.getCheckdetailId());
        type.setText(linkeMain.getType());
        deptId.setText(linkeMain.getDeptId());
        assetNumber.setText(linkeMain.getAssetNumber());
        result.setText(linkeMain.getResult());
        plannum.setText(linkeMain.getPlannum());
        realitynum.setText(linkeMain.getRealitynum());
        realitynum.setSelection(realitynum.getText().length());
        realitynum.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                linkeMain.setRealitynum(s.toString());
            }
        });
        return view;
    }


}
